// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

package com.nnee.p_fk.p_a;

import com.nnee.p_b.p_a.cls_d;
import com.nnee.p_c.cls_j;
import com.nnee.p_e.cls_b;
import com.nnee.p_pr.p_a.cls_i;
import com.nnee.p_pr.p_a.cls_t;
import com.nnee.p_pr.p_a.cls_u;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Vector;
import org.apache.http.HttpHost;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;

// Referenced classes of package com.nnee.p_fk.a:
//            d, m, g

public class cls_a
{

    public cls_a()
    {
        this(4);
    }

    public cls_a(int i1)
    {
        this(4, 5);
    }

    public cls_a(int i1, int j1)
    {
    	super();
    	
        int flag = 0;
        
        p = 4;
        g = false;
        p = i1;
        q = j1;
        c = new cls_j();
        d = new HashMap();
        e = new LinkedList();
        for(; flag < p; flag++)
        {
            com.nnee.p_fk.p_a.cls_d d1 = new com.nnee.p_fk.p_a.cls_d(this);
            d1.setPriority(q);
            e.add(d1);
            d1.start();
        }

    }

    static HttpClient a(cls_a a1)
    {
        return a1.c();
    }

    static boolean a(cls_a a1, cls_m m1)
    {
        return a1.c(m1);
    }

    /**
     * @deprecated Method b is deprecated
     */

    public static int b()
    {
        
        int i1;
        i1 = h;
        h = i1 + 1;
        
        return i1;
        
    }

    private HttpClient c()
    {
        BasicHttpParams basichttpparams = new BasicHttpParams();
        HttpConnectionParams.setConnectionTimeout(basichttpparams, 20000);
        HttpConnectionParams.setSoTimeout(basichttpparams, 60000);
        HttpConnectionParams.setSocketBufferSize(basichttpparams, 8192);
        HttpProtocolParams.setUseExpectContinue(basichttpparams, false);
        DefaultHttpClient defaulthttpclient = new DefaultHttpClient(new ThreadSafeClientConnManager(basichttpparams, a), basichttpparams);
        defaulthttpclient.getParams().setParameter("http.protocol.handle-redirects", Boolean.valueOf(true));
        com.nnee.p_e.cls_d d1 = com.nnee.p_e.cls_b.a(com.nnee.p_b.p_a.cls_d.h().a()).c();
        if(d1 != null && !com.nnee.p_pr.p_a.cls_i.e(d1.d))
        {
            HttpHost httphost = new HttpHost(d1.d, d1.c);
            defaulthttpclient.getParams().setParameter("http.route.default-proxy", httphost);
        }
        return defaulthttpclient;
    }

    private boolean c(cls_m m1)
    {
        boolean flag;
        if(g || m1.u())
            flag = true;
        else
            flag = false;
        return flag;
    }

    private boolean d()
    {
        boolean flag = true;
        Iterator iterator = e.iterator();
while(true)
{
        if(!iterator.hasNext()) {
        	flag = false;
        	return flag;
        }else {
        	 if(((com.nnee.p_fk.p_a.cls_d)iterator.next()).c()) {continue;} else {
        		 flag = true;
        		 return flag;
        	 }
        }
}

    }

    private void e()
    {
        if(e.size() >= p && e.size() < p + r && !d())
        {
            cls_t t1 = cls_u.c(com.nnee.p_b.p_a.cls_d.h().a());
            if(t1 != cls_t.dEWirelessNET && t1 != cls_t.cEWirelessWAP ? System.currentTimeMillis() - b >= 2000L : System.currentTimeMillis() - b >= 8000L)
            {
                cls_g g1 = new cls_g(this);
                synchronized(e)
                {
                    e.add(g1);
                }
                g1.start();
            }
        }
        return;
       
    }

    public Vector a(cls_m m1)
    {
        if(m1 == null || !m1.e())
            return null;
        HashMap hashmap = d;
        
        Vector vector;
        vector = (Vector)d.remove((new StringBuilder()).append(m1.b()).append(m1.l()).toString());
        
        return vector;
    }

    public void a()
    {
        g = true;
        if(f != null)
        {
            f.getConnectionManager().shutdown();
            f = null;
        }
        e.clear();
        d.clear();
        c.f();
        for(Iterator iterator = e.iterator(); iterator.hasNext();)
        {
            com.nnee.p_fk.p_a.cls_d d1 = (com.nnee.p_fk.p_a.cls_d)iterator.next();
            try
            {
                d1.interrupt();
            }
            catch(Exception exception)
            {
                exception.printStackTrace();
            }
        }

        c.e();
    }

    public void a(int i1, int j1)
    {
        c.a(i1, j1);
        if((j1 & 0xff) == 4)
            e();
    }

    public void a(cls_m m1, int i1)
    {
        c.a(m1, i1);
        if((i1 & 0xff) == 4)
            e();
    }

    public void a(Class class1)
    {
        Vector vector = c.a(class1);
        if(vector != null && vector.size() > 0)
        {
            for(Iterator iterator = vector.iterator(); iterator.hasNext(); ((cls_m)iterator.next()).r());
        }
    }

    protected void a(Vector vector)
    {
        if(vector != null && vector.size() > 0)
        {
            cls_m m1;
            for(Iterator iterator = vector.iterator(); iterator.hasNext(); c.a(m1, m1.f()))
                m1 = (cls_m)iterator.next();

        }
    }

    public void b(cls_m m1)
    {
        a(m1, 1);
    }

    static SchemeRegistry a;
    static int h = 0;
    private static final boolean i = false;
    private static final int j = -3;
    private static final int k = 2;
    private static final int l = 60000;
    private static final int m = 2000;
    private static final int n = 8000;
    private static final int o = 4;
    private static int r = 1;
    long b;
    cls_j c;
    HashMap d;
    LinkedList e;
    HttpClient f;
    boolean g;
    private int p;
    private int q;

    static 
    {
        a = new SchemeRegistry();
        a.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
        a.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
        h = 0;
    }
}
